package com.qf.service.impl;

import com.qf.entity.GoodsDetail;
import com.qf.mapper.GoodsDetailMapper;
import com.qf.service.GoodsDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ASUS
 * @version V1.0
 * @Project work
 * @Package com.qf.service.impl
 * @Date 2021/10/3 17:59
 */
@Service
public class GoodsDetailServiceImpl implements GoodsDetailService {

    @Autowired
    private GoodsDetailMapper goodsDetailMapper;

    @Override
    public List<GoodsDetail> findAll(String sort) {
        return goodsDetailMapper.findAll(sort);
    }

    @Override
    public GoodsDetail findById(long id) {
        return goodsDetailMapper.findById(id);
    }

    @Override
    public void update(GoodsDetail goodsDetail) {
        goodsDetail.setRemaining(goodsDetail.getRemaining()-1);
        goodsDetailMapper.updateByPrimaryKeySelective(goodsDetail);
    }
}
